function checking(){
      var ajaxLoading=false;
       if(!ajaxLoading){
            ajaxLoading=true;
            $.ajax({
                url: "checkDb.action",
                type:"post",
                cache:false,
                dataType:"json",
                success:function(data) {

                     if(data.resultDB=="login"){
                                 window.location.href = 'main.action';
                      }else if (data.resultDB == "working") {
                         $("#db").find("div").css("backgroundImage", "url(images/db/working_db.png)");
                         $("#db").find("div").find("input[name='dbCount']").val(0);
                    } else {
                            var dbCount = parseInt($("#db").find("div").find("input[name='dbCount']").val());
                            if (dbCount >= 3) {
                                $("#db").find("div").css("backgroundImage", "url(images/db/not_working_db.png)");
                            } else {
                                $("#db").find("div").css("backgroundImage", "url(images/db/waiting_db1.png)");
                                dbCount = dbCount + 1;
                                $("#db").find("div").find("input[name='dbCount']").val(dbCount);
                            }
                    }
                    if (data.resultServer == "1") {
                            $("#server").find("div").css("backgroundImage", "url(images/server/server1.png)");
                    } else {
                            $("#server").find("div").css("backgroundImage", "url(images/server/server2.png)");
                    }
                }
            });
           ajaxLoading=false;
       }
}

$(document).ready(function() {

            checking();


    setInterval(function(){

              checking();

    }, 180000);

    $(".menulink").hover(function() {
        $(this).parent().find(".submenu").css("display", "block");
        $(this).parent().find(".submenu").css("opacity", 1);
        $(this).parent().find(".submenu").css("z-index", 180);
        $(this).parent().find(".submenu").css("overflow", "visible");
    });

    $(".x").hover(function() {
    }, function() {
        $(this).find("ul").css("display", "none");
    });

    $(".manuf").hover(
                        function() {
                            $.ajax({
                                        url: "getSubMenusManufacturer.action",
                                        type:"post",
                                        cache:false,
                                        success:function(data) {
                                            $(".manuf").parent().find("ul").html(data);
                                        }
                                    });
                        }, function() {
                        }
                     );


    $(".ctype").hover(
            function() {
                $.ajax({
                            url: "getSubMenusTypeCPE.action",
                            type:"post",
                            cache:false,
                            success:function(data) {
                                $(".ctype").parent().find("ul").html(data);
                            }
                        });
            }, function() {
            });


    $(".sub").hover(function(){
        $(this).parent().find("ul").css("display", "block");
        $(this).parent().find("ul").css("opacity", 1);
        $(this).parent().find("ul").css("z-index", 180);
        $(this).parent().find("ul").css("overflow", "visible");
    },
            function() {

            });

});





